# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=openpyxl
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}"
         "${MINGW_PACKAGE_PREFIX}-python2-${_realname}")
pkgver=2.5.0a1
pkgrel=1
pkgdesc="A python library to read/write Excel 2007 xlsx/xlsm file (mingw-w64)"
url="https://openpyxl.readthedocs.io/"
arch=('any')
license=('MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python3-jdcal"
             "${MINGW_PACKAGE_PREFIX}-python2-jdcal"
             "${MINGW_PACKAGE_PREFIX}-python3-et-xmlfile"
             "${MINGW_PACKAGE_PREFIX}-python2-et-xmlfile")
_dtoken="28/c5/7e7d4062eccf8f4bbd91a9cc503af702e1a5dd2ccf196dbdebcb5b26c576"
source=("https://pypi.python.org/packages/${_dtoken}/openpyxl-${pkgver}.tar.gz"
        "LICENSE")
sha256sums=('b53bf1711b8f90de16936e702a28d5074f1c75dd81ac6ea5131b62d81c057730'
            '0c1a4c0d3ea3fe274145e211f4c2e7de6f1747e3a086610c4ae70aca2ec9d50c')

prepare() {
  cp -a openpyxl-${pkgver} openpyxl-${pkgver}-py2
#  cd openpyxl-${pkgver}-py2
#
#  sed -e "s|#![ ]*/usr/bin/python$|#!/usr/bin/python2|" \
#      -e "s|#![ ]*/usr/bin/env python$|#!/usr/bin/env python2|" \
#      -e "s|#![ ]*/bin/env python$|#!/usr/bin/env python2|" \
#      -i $(find . -name '*.py')
}

build() {
  cd ${srcdir}/${_realname}-${pkgver}
  python3 setup.py build

  cd ${srcdir}/${_realname}-${pkgver}-py2
  python2 setup.py build
}

package_python3-openpyxl() {
  depends=(
    "${MINGW_PACKAGE_PREFIX}-python3-jdcal"
    "${MINGW_PACKAGE_PREFIX}-python3-et-xmlfile"
  )

  cd ${srcdir}/${_realname}-${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1
  install -Dm644 ${srcdir}/LICENSE ${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE
}

package_python2-openpyxl() {
  depends=(
    "${MINGW_PACKAGE_PREFIX}-python2-jdcal"
    "${MINGW_PACKAGE_PREFIX}-python2-et-xmlfile"
  )

  cd ${srcdir}/${_realname}-${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1
  install -Dm644 ${srcdir}/LICENSE ${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE
}

package_mingw-w64-i686-python2-openpyxl() {
  package_python2-openpyxl
}

package_mingw-w64-i686-python3-openpyxl() {
  package_python3-openpyxl
}

package_mingw-w64-x86_64-python2-openpyxl() {
  package_python2-openpyxl
}

package_mingw-w64-x86_64-python3-openpyxl() {
  package_python3-openpyxl
}

# vim:set ts=2 sw=2 et:
